﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace 药品信息管理
{
    public partial class MainForm : DevComponents.DotNetBar.Office2007RibbonForm
    {
        public MainForm()
        {
            InitializeComponent();
        }
        #region 子窗只能打开一个
        private bool checkChildFrmExist(string childFrmName)
        {
            foreach (Form childFrm in this.MdiChildren)
            {
                //用子窗体的Name进行判断，如果已经存在则将他激活
                if (childFrm.Name == childFrmName)
                {
                    if (childFrm.WindowState == FormWindowState.Minimized)
                        childFrm.WindowState = FormWindowState.Maximized;
                    childFrm.Activate();
                    return true;
                }
            }
            return false;
        }
        #endregion

        private void MainForm_Load(object sender, EventArgs e)
        {
            eStyle style = (eStyle)Enum.Parse(typeof(eStyle), "Windows7Blue");
            StyleManager.ChangeStyle(style, Color.Empty);
        }

        private void Swith_Executed(object sender, EventArgs e)
        {
            ribbonControl1.Expanded = Swith.Checked;
            Swith.Checked = !Swith.Checked;
        }

        private void AppCommandTheme_Executed(object sender, EventArgs e)
        {
            ICommandSource source = sender as ICommandSource;
            if (source.CommandParameter is string)
            {
                eStyle style = (eStyle)Enum.Parse(typeof(eStyle), source.CommandParameter.ToString());
                // Using StyleManager change the style and color tinting
                StyleManager.ChangeStyle(style, Color.Empty);
                if (style == eStyle.Office2007Black || style == eStyle.Office2007Blue || style == eStyle.Office2007Silver || style == eStyle.Office2007VistaGlass)
                    buttonFile.BackstageTabEnabled = false;
                else
                    buttonFile.BackstageTabEnabled = true;

            }
            else if (source.CommandParameter is Color)
            {
                StyleManager.ColorTint = (Color)source.CommandParameter;
            }
        }

        private void buttonStyleCustom_ColorPreview(object sender, ColorPreviewEventArgs e)
        {
            StyleManager.ColorTint = e.Color;
        }

        private void buttonItem2_Click(object sender, EventArgs e)
        {
            if (this.checkChildFrmExist("YP_ZDWH") == true)
            {
                return;
            }
            YP_ZDWH ZDWH = new YP_ZDWH();
            ZDWH.MdiParent = this;
            ZDWH.WindowState = FormWindowState.Maximized;
            ZDWH.Show();
        }

        private void buttonItem5_Click(object sender, EventArgs e)
        {
            if (this.checkChildFrmExist("YP_JBGL") == true)
            {
                return;
            }
            YP_JBGL JBGL = new YP_JBGL();
            JBGL.MdiParent = this;
            JBGL.WindowState = FormWindowState.Maximized;
            JBGL.Show();
        }

        private void buttonItem6_Click(object sender, EventArgs e)
        {

        }

    }
}